<?php
require 'include/global.php';
if(!$_SESSION[uname]){
require_once 'include/train_db.php';
}
$nav = new buildNav;
switch($_GET['list']){
   case employer:
	   unset($data_list);
       
       $headlist = array("User Name","Industry","Company Size","Location","Date");
       $total = $DB->fetch_one_array("SELECT COUNT(*) AS count FROM pa_employer");
       $nav->total_result = $total[count];
       $nav->execute("SELECT * FROM pa_employer ORDER BY ep_id DESC");
	   $nav->show = 1;
	   $page = $nav->pagenav();
	   $smarty->assign("page",$page);
	   $i=0;
		while($list = $DB->fetch_array($nav->sql_result)){
		   $data_list[$i][a0] =$list[ep_uname];
		   $data_list[$i][a1] =($list[ep_industry]!=0)?$jobcategory[$list[ep_industry]]:"N/A";
		   $data_list[$i][a2] =$list[ep_copsize];
		   $a = ($list[ep_state]!=0)?$state[$list[ep_state]]:"N/A";
		   $b = ($list[ep_country]!=0)?$country[$list[ep_country]]:"N/A";
		   $data_list[$i][a3] = $a.",".$b;
		   $data_list[$i][a4] =date("m/d/Y",$list[ep_regtime]);
		  $i++;
		}
        $smarty->assign("title","Employer");
		$smarty->assign("headlist",$headlist);
		$smarty->assign("contentlist",$data_list);
	   break;
   case candidate:
	   unset($data_list);
       
       $headlist = array("User Name","Industry","Job Title","Location","Date");
	   $total = $DB->fetch_one_array("SELECT COUNT(*) AS count FROM pa_candidates");
	   $nav->total_result = $total[count];
	   $nav->execute("SELECT * FROM pa_candidates ORDER BY js_id DESC");
	   $nav->show = 1;
	   $page = $nav->pagenav();
	   $smarty->assign("page",$page);
	   $i=0;
		while($list = $DB->fetch_array($nav->sql_result)){
		   $data_list[$i][a0] =$list[js_uname];
		   $data_list[$i][a1] =($list[js_industry]!=0)?$jobcategory[$list[js_industry]]:"N/A";
		   $data_list[$i][a2] =$list[js_title];
		   $a = ($list[js_state]!=0)?$state[$list[js_state]]:"N/A";
		   $b = ($list[js_country]!=0)?$country[$list[js_country]]:"N/A";
		   $data_list[$i][a3] = $a.",".$b;
		   $data_list[$i][a4] =date("m/d/Y",$list[js_regtime]);
		   $i++;
		}
        $smarty->assign("title","Candidates");
		$smarty->assign("headlist",$headlist);
		$smarty->assign("contentlist",$data_list);
   	   break;
	case recruiter:
	   unset($data_list);
	   
       //$headlist = array("Name","Industry","Specialty","Location","E-mail");
	   $headlist = array("User Name","Industry","Specialty","Location","Date");
	   $total = $DB->fetch_one_array("SELECT COUNT(*) AS count FROM pa_recuiter");
	   $nav->total_result = $total[count];
	   $nav->execute("SELECT * FROM pa_recuiter ORDER BY rc_id DESC");
	   $nav->show = 1;
	   $page = $nav->pagenav();
	   $smarty->assign("page",$page);
	   $i=0;
		while($list = $DB->fetch_array($nav->sql_result)){
		   $data_list[$i][a0] =$list[rc_uname];
		   $data_list[$i][a1] =($list[rc_industry]!=0)?$jobcategory[$list[rc_industry]]:"N/A";
		   $data_list[$i][a2] =$jobfunction[$list[rc_recruit]];
		   $a = ($list[rc_state]!=0)?$state[$list[rc_state]]:"N/A";
		   $b = ($list[rc_country]!=0)?$country[$list[rc_country]]:"N/A";
		   $data_list[$i][a3] = $a.",".$b;
		  // $data_list[$i][a4] ="<a href='mailto:$list[rc_email]'>".$list[rc_email]."</a>";
		   $data_list[$i][a4] = @date("m/d/Y",$list[rc_regtime]);
		   $data_list[$i][link] = "<a href=recdetail.php?id=$list[rc_id]>";
		   $i++;
		}
        $smarty->assign("title","Recruiters");
		$smarty->assign("headlist",$headlist);
		$smarty->assign("contentlist",$data_list);
   	   break;
	case advisor:
	   unset($data_list);
	    
       $headlist = array("User Name","Specialty","Date");
	   $total = $DB->fetch_one_array("SELECT COUNT(*) AS count FROM pa_advisory");
	   $nav->total_result = $total[count];
	   $nav->execute("SELECT * FROM pa_advisory ORDER BY ad_id DESC");
	   $nav->show = 1;
	   $page = $nav->pagenav();
	   $smarty->assign("page",$page);
	   $i=0;
		while($list = $DB->fetch_array($nav->sql_result)){
		   $data_list[$i][a0]    = $list[ad_uname];
		   $data_list[$i][urlid] = $list[ad_uid];
		   $data_list[$i][a1]    = $list[ad_specialty];
		   $data_list[$i][a2]    = date("m/d/Y",$list[ad_regtime]);
		   $data_list[$i][link] = "<a href=advisordetail.php?id=$list[ad_id]>";
		  // $data_list[$i][a3]    = $list[ad_time];
		  // $data_list[$i][a4]    = $list[ad_email];
		  // $data_list[$i][a5]    ="<a href=\"skype:$list[ad_skype]?chat\"><img src=\"http://mystatus.skype.com/balloon/$list[ad_skype]\" style=\"border: none;\" width=\"150\" height=\"60\" alt=\"My status\" /></a>";
		   $i++;
		}
        $smarty->assign("title","Advisor");
		$smarty->assign("headlist",$headlist);
		$smarty->assign("contentlist",$data_list);
   	   break;

	 case allevents:
	   unset($data_list);
	    $order = "ORDER BY tr_id DESC";
			if($_GET[tp]==1){
				$_GET[order1]==''&&$order1=1;$_GET[order2]==''&&$order2=1;
				switch($_GET[swh]){
				   case 1:
					   $by = "tr_date";
					   if($_GET[order1]==1){$order_arr[1]=2; $orderp=" DESC ";$image_arr[1] = "<img src=\"images/dot1.gif\" align=\"absmiddle\">";}else{$order_arr[1]=1;$orderp=" ASC ";$image_arr[1] = "<img src=\"images/dot2.gif\"  align=\"absmiddle\">";}
					   $order = " ORDER BY $by $orderp";
					   break;
				   case 2:
					   $by = "tr_topic";
					   if($_GET[order2]==1){$order_arr[2]=2; $orderp=" DESC ";$image_arr[2] = "<img src=\"images/dot1.gif\"  align=\"absmiddle\">";}else{$order_arr[2]=1;$orderp=" ASC ";$image_arr[2] = "<img src=\"images/dot2.gif\"  align=\"absmiddle\">";}
					   $order = " ORDER BY $by $orderp";
					   break;
				}
				
			}

       $headlist = array("<a href=\"indexlist.php?list=allevents&order1=$order_arr[1]&swh=1&tp=1\">Date ".$image_arr[1]."</a>","<a href=\"indexlist.php?list=allevents&order2=$order_arr[2]&swh=2&tp=1\">Topic ".$image_arr[2]."</a>","Location","Host Name");
	   $total = $DB->fetch_one_array("SELECT COUNT(*) AS count FROM pa_training");
	   $nav->total_result = $total[count];
	   $nav->execute("SELECT * FROM pa_training $order");
	   $nav->show = 1;
	   $page = $nav->pagenav();
	   $smarty->assign("page",$page);
	   $i=0;
		while($list = $DB->fetch_array($nav->sql_result)){
		   $data_list[$i][a0]    = date("m/d/Y",strtotime($list[tr_date]));
		   $data_list[$i][a1]    = $list[tr_topic];
		   $data_list[$i][a2]    = $list[tr_location];
		   $data_list[$i][a3]    = $list[tr_name];
           $data_list[$i][left]  = '<a href="training.php?tid='.$list[tr_id].'">';
		   
		   $i++;
		}
	    $smarty->assign("aright",'</a>');
        $smarty->assign("title","All Events");
		$smarty->assign("headlist",$headlist);
		$smarty->assign("contentlist",$data_list);
   	   break;
	   
}


$smarty->display('header.tpl');
if($_SESSION[uname]){
require './include/all_left.php';
$smarty->display('allleft.tpl');
}else{
$smarty->display('left.tpl');
}


$smarty->display('indexlist.tpl');


if($_SESSION[uname]){
require_once './include/advisory_db.php';
$smarty->display('allright.tpl');
}else{
$smarty->display('right.tpl');
}
$smarty->display('footer.tpl');


?>
